import hashlib
import json
import random

import requests


def make_sha256_digest(content):
    return hashlib.md5(content.encode()).hexdigest()





def gen_verify_code(length = 4):
    '''生成指定长度验证码'''

    all_chars = '0123456789abcdefghijklmnopqrstuvwxyz'
    return ''.join(random.choices(all_chars,k = length))



def gen_mobile_code(length=4):
    all_charts = '0123456789'
    return ''.join(random.choices(all_charts,k = length))



def send_mobile_code(tel,code):

    resp = requests.post("http://sms-api.luosimao.com/v1/send.json",
        auth=("api", "key-344844969782d1ff4619c4239a73c0d7"),
        data={
                "mobile": tel,
                "message": f'小主，这是你的验证码哟:{code}，千万不要让人知道哦【铁壳测试】'
            },
        # timeout=3,
        verify=False
            )
    result = json.loads(resp.text)
    print(code)
    print(result)
    return result
